﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户管理</title>
    <!--引入 element-ui 的样式，-->
    <link rel="stylesheet" href="../../assets/css/elementui.css">
    <link ref="stylesheet" href="../../assets/css/print.min.css">
    <style>
        [v-cloak] {
            display: none;
        }

        .el-row .el-form-item {
            margin-bottom: 0px;
            text-align: center;
        }

        .el-row .el-col {
            border-right: 1px solid black;
        }

        .el-row {
            border: 1px solid black;
            margin-bottom: -1px !important;
        }

        .el-input input {
            padding: 0px;
        }

        .el-input .el-input__inner {
            padding: 0px;
        }

        .el-input__suffix {
            display: none;
        }

        .info {
            text-align: left !important;
        }

        h5, p {
            margin: 0px;
            text-align: left;
        }

        .text-center input {
            text-align: center;
        }
    </style>
</head>
<body>
<!-- 正文开始 -->
<div id="app" v-cloak>
    <el-form inline="true" :model="searchForm" label-width="80px">
        <el-form-item>
            <el-input v-model="searchForm.idNum" placeholder="身份证" clearable></el-input>
        </el-form-item>
        <el-form-item>
            <el-input v-model="searchForm.name" placeholder="员工姓名" clearable></el-input>
        </el-form-item>
        <el-form-item>
            <el-input v-model="searchForm.account" placeholder="工号" clearable></el-input>
        </el-form-item>
        <el-form-item label="">
            <el-checkbox v-for="(item,i) in statusList" v-model="item.checked" :label="item.label"
                         :key="i"></el-checkbox>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="search">查询</el-button>
            <el-button type="success" @click="exportData">导出</el-button>
            <el-tooltip class="item" effect="dark" content="仅可导出在职员工信息" placement="top-start">
                <i class="el-icon-warning-outline"></i>
            </el-tooltip>
        </el-form-item>
    </el-form>
    <el-card>
        <el-button size="mini" @click="handleCurrentRow">添加用户
            <el-tooltip class="item" effect="dark" content="仅可用于添加外协工号，金鑫员工请走入职流程" placement="top-start">
                <i class="el-icon-warning"></i>
            </el-tooltip>
        </el-button>
        <el-table
                :data="tableData"
                border
                style="width: 100%"
        >
            <el-table-column
                    prop="name"
                    width="80"
                    label="姓名">
            </el-table-column>
            <el-table-column
                    prop="account"
                    width="100"
                    label="工号">
                <template slot-scope="scope">
                    {{ scope.row.account?scope.row.account:'无'}}
                </template>
            </el-table-column>
            <el-table-column
                    prop="org"
                    width="120"
                    label="部门">
                <template slot-scope="scope">
                    {{ scope.row.orgName?scope.row.orgName:'无'}}
                </template>
            </el-table-column>
            <el-table-column
                    prop="idNum"
                    width="180"
                    label="身份证号">
            </el-table-column>
            <el-table-column
                    prop="zhusu"
                    label="是否住宿"
                    width="100">

            </el-table-column>
            <el-table-column
                    prop="zhicheng"
                    label="职称"
                    width="120">

            </el-table-column>

            <el-table-column
                    prop="zydj"
                    label="专业等级"
                    width="120">

            </el-table-column>
            <el-table-column
                    prop="sex"
                    label="性别"
                    width="60">
                <template slot-scope="scope">
                    {{ scope.row.sex}}
                </template>
            </el-table-column>
            <el-table-column
                    prop="lock"
                    label="是否锁定"
                    width="180">
                <template slot="header" slot-scope="scope">
                    是否锁定
                    <el-tooltip content="点击已锁定，状态变为未提交，点击已提交状态变为已锁定（仅“未提交”状态员工可以编辑信息）" placement="right-start">
                        <i class="el-icon-warning"></i>
                    </el-tooltip>
                </template>
                <template slot-scope="scope">
                    <el-button size="mini" type="warning" @click="changeLockStatus(scope.row)">
                        <span v-if="scope.row.lock==1">已提交</span>
                        <span v-else-if="scope.row.lock==2">未提交</span>
                        <span v-else-if="scope.row.lock==3">已锁定</span>
                        <span v-else>无状态</span>
                    </el-button>
                </template>
            </el-table-column>
            <el-table-column
                    label="操作"
                    fixed="right"
            >
                <template slot-scope="scope">
                    <el-button @click="handleEdit(scope.row)" type="text" size="small">详情</el-button>

                    <div v-if="scope.row.lock==3">
                        <el-button @click="openHire(scope.row)" type="text" size="small">
                            录用审批
                        </el-button>
                        <el-button @click="openNewTrain(scope.row)" type="text" size="small">
                            培训审批
                        </el-button>
                        <el-button @click="openEnsure(scope.row)" type="text" size="small">
                            承诺及职业危害
                        </el-button>
                        <el-button @click="openContract(scope.row)" type="text" size="small">
                            劳动合同
                        </el-button>
                        <el-button @click="handleCurrentRow(scope.row)" size="mini" type="text">
                            修改
                        </el-button>
                        <el-button @click="handleLeave(scope.row)" size="mini" type="text">
                            离职
                        </el-button>
                        <el-button @click="openHireList(scope.row)" size="mini" type="text">
                            入职清单
                        </el-button>
                    </div>

                    <el-button v-if="!scope.row.status" size="mini" type="text" @click="handleRemove(scope.row)">
                        删除
                    </el-button>

                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page.sync="page.currentPage"
                :page-size="page.rows"
                layout="total, sizes, prev, pager, next"
                :page-sizes="[10, 20, 50]"
                :total="page.total">
        </el-pagination>
    </el-card>
    <!--员工登记表-->
    <el-dialog
            title="员工登记表"
            :visible.sync="dialogVisible"
            width="80%"

            :before-close="handleClose">
        <el-form id="dengji">
            <div style="display: flex;justify-content: space-around">
                <div>编号：JXQ/BGZH01-05/A</div>
                <div>NO.：ZH{{currentRow.approveNum}}{{currentRow.num<10?'0'+currentRow.num:currentRow.num}}&nbsp;&nbsp;&nbsp;&nbsp;保存期：3年</div>
            </div>
            <a size="mini" style="position: absolute;top:2em;right: 4em" @click="handlePrint('员工登记表')">
                <i class="el-icon-printer"></i>
            </a>
            <el-row>
                <el-col span="20">
                    <el-row>
                        <el-col :span="2">
                            <el-form-item>姓名</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.name"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>性别</el-form-item>
                        </el-col>
                        <el-col :span="4">
                            <el-form-item>
                                <el-select v-model="currentRow.sex" placeholder="请选择">
                                    <el-option v-for="item in sexOption" :key="item.value" :label="item.label"
                                               :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>出生年月</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.birthTime"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>政治面貌</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.political"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="2">
                            <el-form-item>籍贯</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.homeTown"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>文化程度</el-form-item>
                        </el-col>
                        <el-col :span="4">
                            <el-form-item>
                                <el-select v-model="currentRow.edu" placeholder="请选择">
                                    <el-option v-for="item in eduOption" :key="item.value" :label="item.label"
                                               :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>健康状况</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.health"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>重大疾病史</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.sick"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="2">
                            <el-form-item>婚否</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-select v-model="currentRow.single" placeholder="请选择">
                                    <el-option v-for="item in singleOption" :key="item.value" :label="item.label"
                                               :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>联系电话</el-form-item>
                        </el-col>
                        <el-col :span="4">
                            <el-form-item>
                                <el-input v-model="currentRow.phone" style="font-size: 0.4em"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>紧急情况联系人电话</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>
                                <el-input v-model="currentRow.warnPhone"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-col>
                <el-col span="4">
                    <div style="height: 9em">
                        <el-image fit="fit" style="width: 100%;height: 100%;"
                                  :src="handleImg(currentRow.img)"></el-image>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="5">
                    <el-form-item>身份证号</el-form-item>
                </el-col>
                <el-col :span="19">
                    <el-form-item>
                        <el-input v-model="currentRow.idNum"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="5">
                    <el-form-item>家庭住址</el-form-item>
                </el-col>
                <el-col :span="19">
                    <el-form-item>
                        <el-input v-model="currentRow.livePlace"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="5">
                    <el-form-item>户口所在地</el-form-item>
                </el-col>
                <el-col :span="19">
                    <el-form-item>
                        <el-input v-model="currentRow.idPlace"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="10">
                    <el-form-item>所获经济、行政或法律处罚情况</el-form-item>
                </el-col>
                <el-col :span="14">
                    <el-form-item>
                        <el-input type="textarea" v-model="currentRow.punish"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item>家庭主要成员及社会关系</el-form-item>
                </el-col>
                <el-col :span="18">
                    <el-row>
                        <el-col :span="6">
                            <el-form-item>称谓</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>称谓</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>工作单位及职业</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>联系方式</el-form-item>
                        </el-col>
                    </el-row>
                    <el-row v-for="(item,i) in relationList" :key="i">
                        <el-col :span="6">
                            <el-form-item>{{item.label}}</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>{{item.name}}</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>{{item.job}}</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>{{item.phone}}</el-form-item>
                        </el-col>
                    </el-row>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item style="text-align: left">学习经历（从最高学历开始填写）</el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-row>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">学校/学院名称</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">起止年月</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">专业及所获文凭</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">证明人</el-form-item>
                    </el-col>
                </el-row>
                <el-row v-for="(item,i) in eduList" :key="i">
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.schoolName}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.startTime}}-{{item.endTime}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.major}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.confirmName}}</el-form-item>
                    </el-col>
                </el-row>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item style="text-align: left">参加过学校或何种技术培训班，获何证书（若没有，请注明无）</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item style="text-align: left">
                        <el-form-item>
                            <el-input type="textarea"
                                      v-model="skillListStr"
                                      :rows="3"></el-input>
                        </el-form-item>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item style="text-align: left">工作经历（按时间顺序填写，必须填写应聘前工作单位）</el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-row>
                    <el-col :span="5">
                        <el-form-item style="text-align: left">单位名称</el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item style="text-align: left">起止年月</el-form-item>
                    </el-col>
                    <el-col :span="5">
                        <el-form-item style="text-align: left">离职原因</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">是否有职业危害接触情况</el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item style="text-align: left">证明人</el-form-item>
                    </el-col>
                </el-row>
                <el-row v-for="(item,i) in workList" :key="i">
                    <el-col :span="5">
                        <el-form-item style="text-align: left">{{item.company}}</el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item style="text-align: left">{{item.startTime}}-{{item.endTime}}</el-form-item>
                    </el-col>
                    <el-col :span="5">
                        <el-form-item style="text-align: left">{{item.leaveReason}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.risk}}</el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item style="text-align: left">{{item.confirmName}}</el-form-item>
                    </el-col>
                </el-row>
            </el-row>
            <el-row>
                <p>
                    本人声明：本人以上所述均属事实，未有任何虚假陈述，未有任何重大隐瞒，否则由此引起的任何法律和经济责任由本人承担。以上信息如有变更本人将及时通知单位，否则本人愿承担一切责任
                </p>
                <div style="float: right">{{dateFormatter(currentRow.upTime)}}</div>
            </el-row>
            <el-row>
                <el-col :span="10">
                    <el-form-item>健康审查表</el-form-item>
                </el-col>
                <el-col :span="14">
                    <el-form-item v-if="currentRow.healthPdf&&currentRow.healthPdf!=''">
                        <el-button @click="viewHealthPdf" type="primary">点击查看健康表</el-button>
                    </el-form-item>
                    <el-form-item v-else>
                        <div style="text-align: left;margin-left: 2em">
                            <el-button @click="chooseFile" type="primary">选择文件</el-button>
                            <span>{{fileName}}</span>
                        </div>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
            <el-button type="primary" @click="handleSaveHealthPdf" size="mini"
                       v-if="currentRow.healthPdf">确 定</el-button>
        </span>
    </el-dialog>
    <!--录用审批-->
    <el-dialog
            title="录用审批"
            :visible.sync="hireDialog"
            width="80%">
        <el-form id="luyong" style="text-align: center">
            <div style="display: flex;justify-content: space-around">
                <div>编号：JXQ/BGZH01-05/A</div>
                <div>NO.：ZH{{currentRow.approveNum}}{{currentRow.num<10?'0'+currentRow.num:currentRow.num}}&nbsp;&nbsp;&nbsp;&nbsp;保存期：3年</div>
            </div>
            <a size="mini" style="position: absolute;top:2em;right: 4em" @click="handlePrintHire('员工录用审批')">
                <i class="el-icon-printer"></i>
            </a>
            <el-row>
                <el-col :span="3">
                    <el-form-item>姓名</el-form-item>
                </el-col>
                <el-col :span="2">
                    <el-form-item>性别</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>出生年月</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>文化程度</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>婚否</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>录用部门</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>录用时间</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>岗位</el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.name" class="text-center"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="2">
                    <el-form-item>
                        <el-select v-model="currentRow.sex" class="text-center" placeholder="请选择">
                            <el-option v-for="item in sexOption" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.birthTime" class="text-center"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-select v-model="currentRow.edu" class="text-center">
                            <el-option v-for="(item,i) in eduOption" :key="i" :label="item.label"
                                       :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-select v-model="currentRow.single" class="text-center" placeholder="请选择">
                            <el-option v-for="item in singleOption" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.orgId"
                                   class="text-center"
                                   @change="handleOrgChange"
                                   filterable
                        >
                            <el-option v-for="(item,i) in orgList" :key="i" :label="item.orgName"
                                       :value="item.orgId"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.hireTime" class="text-center"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.job" class="text-center"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item>面试结论</el-form-item>
                </el-col>
                <el-col :span="18">
                    <el-form-item>
                        <el-input v-model="currentRow.audition" type="textarea" rows="4"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row v-for="(item,i) in hireApproveList" :key="i">
                <el-col :span="6">
                    <el-form-item> {{handleOrgName(item[0].name)}}</el-form-item>
                </el-col>
                <el-col :span="18">
                    <el-form-item>
                        <div v-if="item[0].approveInfo" style="position: relative">
                            <el-input readonly v-model="item[0].approveInfo.comment" type="textarea"
                                      autosize></el-input>
                            <div style="position: absolute;right: 2em;top:1em">
                                {{item[0].approveInfo.name}}/{{item[0].approveInfo.approveDate}}
                            </div>
                        </div>
                        <el-input v-else readonly type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="hireDialog = false" size="mini">取 消</el-button>
            <el-button type="primary" @click="handleSaveHire" v-if="currentRow.hireApprove!=1"
                       size="mini">确 定</el-button>
        </span>
    </el-dialog>
    <!--员工培训-->
    <el-dialog
            title="培训审批"
            :visible.sync="newTrainDialog"
            width="80%">
        <el-form id="peixun">
            <a size="mini" style="position: absolute;top:2em;right: 4em" @click="handlePrintNewTrain('入职培训')">
                <i class="el-icon-printer"></i>
            </a>
            <el-row>
                <el-col :span="4">
                    <el-form-item>姓名</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="currentRow.name"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>性别</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.sex">
                            <el-option v-for="(item,i) in sexOption" :key="i" :label="item.label"
                                       :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>文化程度</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.edu">
                            <el-option v-for="(item,i) in eduOption" :key="i" :label="item.label"
                                       :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="4">
                    <el-form-item>录用部门</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.orgId"
                                   @change="handleOrgChange"
                                   filterable
                        >
                            <el-option v-for="(item,i) in orgList" :key="i" :label="item.orgName"
                                       :value="item.orgId"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>入职时间</el-form-item>
                </el-col>

                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="currentRow.hireTime"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>岗位</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="currentRow.job"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="18">
                    <el-form-item>培训内容</el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>培训讲师</el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>企业文化</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <h5>进行企业文化宣导培训</h5>
                        <p>公司简介：包含公司发展历史，目前状况等</p>
                        <p>企业文化：包含公司经营理念，核心价值观等</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <div v-if="trainApproveList[0] &&trainApproveList[0].approveInfo" style="position: relative">
                            <el-input readonly v-model="trainApproveList[0].approveInfo.comment" type="textarea"
                                      autosize></el-input>
                            <div style="position: absolute;right: 2em;top:1em">
                                {{trainApproveList[0].approveInfo.name}}/{{trainApproveList[0].approveInfo.approveDate}}
                            </div>
                        </div>
                        <el-input v-else readonly type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>企业制度</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <h5>进行企业管理制度宣读培训</h5>
                        <p>休息、休假、考勤制度，入离职制度，转正制度、奖惩制度、行为规范、工作纪律、合同、薪酬待遇、福利待遇、保密制度等</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <div v-if="trainApproveList[0] &&trainApproveList[0].approveInfo" style="position: relative">
                            <el-input readonly v-model="trainApproveList[0].approveInfo.comment" type="textarea"
                                      autosize></el-input>
                            <div style="position: absolute;right: 2em;top:1em">
                                {{trainApproveList[0].approveInfo.name}}/{{trainApproveList[0].approveInfo.approveDate}}
                            </div>
                        </div>
                        <el-input v-else readonly type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>质量方针与意识</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <p>公司 质量方针的培训</p>
                        <p>公司质量意识的培训</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <div v-if="trainApproveList[1] &&trainApproveList[1].approveInfo" style="position: relative">
                            <el-input readonly v-model="trainApproveList[1].approveInfo.comment" type="textarea"
                                      autosize></el-input>
                            <div style="position: absolute;right: 2em;top:1em">
                                {{trainApproveList[1].approveInfo.name}}/{{trainApproveList[1].approveInfo.approveDate}}
                            </div>
                        </div>
                        <el-input v-else readonly type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>安全教育培训</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <h5>进行现场规章知道胡和遵章守纪教育</h5>
                        <p>公司必须遵守的安全事项</p>
                        <p>现场内可能存在的不安全因素</p>
                        <p>现场安全生产制度、规定和安全注意事项</p>
                        <p>个人劳动防护用品及劳保用品的穿戴规范</p>
                        <p>职业卫生健康知识</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <div v-if="trainApproveList[2] &&trainApproveList[2].approveInfo" style="position: relative">
                            <el-input readonly v-model="trainApproveList[2].approveInfo.comment" type="textarea"
                                      autosize></el-input>
                            <div style="position: absolute;right: 2em;top:1em">
                                {{trainApproveList[2].approveInfo.name}}/{{trainApproveList[2].approveInfo.approveDate}}
                            </div>
                        </div>
                        <el-input v-else readonly type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>岗位职责与权限</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <p>岗位的职责</p>
                        <p>岗位的权限</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <div v-if="trainApproveList[3] &&trainApproveList[3].approveInfo" style="position: relative">
                            <el-input readonly v-model="trainApproveList[3].approveInfo.comment" type="textarea"
                                      autosize></el-input>
                            <div style="position: absolute;right: 2em;top:1em">
                                {{trainApproveList[3].approveInfo.name}}/{{trainApproveList[3].approveInfo.approveDate}}
                            </div>
                        </div>
                        <el-input v-else readonly type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="newTrainDialog = false" size="mini">取 消</el-button>
            <el-button v-if="currentRow.trainApprove!=1" type="primary" @click="handleSaveNewTrain"
                       size="mini">确 定</el-button>
        </span>
    </el-dialog>
    <!--合同-->
    <el-dialog
            title="合同信息"
            :visible.sync="contractDialog"
            width="60%">
        <el-form :model="contractForm" label-width="120px">
            <el-form-item label="上次签署时间">
                <el-input v-model="contractForm.lastSignTime" readonly></el-input>
            </el-form-item>
            <el-form-item label="姓名">
                <el-input v-model="contractForm.name" readonly></el-input>
            </el-form-item>
            <el-form-item label="身份证">
                <el-input v-model="contractForm.account" readonly></el-input>
            </el-form-item>
            <el-form-item label="接收手机">
                <el-input v-model="contractForm.phone" readonly></el-input>
            </el-form-item>
            <el-form-item label="合同失效时间">
                <el-date-picker
                        v-model="contractForm.expTime"
                        :default-value="getDateTimeStr(5)"
                        type="datetime"
                        placeholder="选择日期时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="上传合同">
                <el-upload
                        :action="action"
                        accept=".pdf"
                        limit="1"
                        ref="upload"
                        :headers="getTokenHeader()"
                        :data="getUploadContractData()"
                        :auto-upload="false"
                        :on-success="uploadSuccess"
                >
                    <el-button type="primary">上传合同<i class="el-icon-upload el-icon--right"></i></el-button>
                </el-upload>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="contractDialog = false" size="mini">取 消</el-button>
            <el-button type="primary" @click="handleSendContract" size="mini">
                发送合同
            </el-button>
        </span>

    </el-dialog>
    <!--承诺及危害告知书-->
    <el-dialog
            title="承诺及危害告知书"
            :visible.sync="ensureDialog"
            width="60%">
        <el-form :model="contractForm" label-width="120px">
            <el-form-item label="上次签署时间">
                <el-input v-model="contractForm.lastSignTime" readonly></el-input>
            </el-form-item>
            <el-form-item label="姓名">
                <el-input v-model="contractForm.name" readonly></el-input>
            </el-form-item>
            <el-form-item label="身份证">
                <el-input v-model="contractForm.account" readonly></el-input>
            </el-form-item>
            <el-form-item label="接收手机">
                <el-input v-model="contractForm.phone" readonly></el-input>
            </el-form-item>
            <el-form-item label="失效时间">
                <el-date-picker
                        v-model="contractForm.expTime"
                        :default-value="getDateTimeStr(5)"
                        type="datetime"
                        placeholder="选择日期时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="上传告知书">
                <el-upload
                        :action="action"
                        accept=".pdf"
                        limit="1"
                        ref="uploadEnsure"
                        :headers="getTokenHeader()"
                        :data="getUploadEnsureData()"
                        :auto-upload="false"
                        :on-success="uploadEnsureSuccess"
                >
                    <el-button type="primary"><i class="el-icon-upload el-icon--right">上传告知书</i></el-button>
                </el-upload>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="contractDialog = false" size="mini">取 消</el-button>
            <el-button type="primary" @click="handleSendEnsure" size="mini">
                发送告知书
            </el-button>
        </span>

    </el-dialog>
    <!--个人信息-->
    <el-dialog title="用户信息" :visible.sync="currentRowDialog">
        <el-form :model="currentRow" label-width="120px">
            <el-form-item label="姓名">
                <el-input v-model="currentRow.name"></el-input>
            </el-form-item>
            <el-form-item label="工号">
                <el-input v-model="currentRow.account" :readonly="currentRow.detailId"></el-input>
            </el-form-item>
            <el-form-item label="性别">
                <el-select v-model="currentRow.sex">
                    <el-option v-for="(item,i) in sexOption" :key="i" :label="item.label"
                               :value="item.value"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="部门">
                <el-cascader
                        v-model="currentRow.orgId"
                        style="width: 100%"
                        :props="{ checkStrictly: true }"
                        filterable
                        clearable
                        :options="orgOptions"
                ></el-cascader>
            </el-form-item>
            <el-form-item label="角色">
                <el-select v-model="currentUserRoles"
                           filterable
                           multiple
                           style="width: 100%"
                >
                    <el-option v-for="(item,i) in roleList"
                               :key="i"
                               :label="item.roleName"
                               :value="item.roleId"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="系统权限">
                <el-checkbox-group
                        v-model="checkedSystemAuthList"
                        @change="changeSystemAuth"

                >
                    <el-checkbox v-for="item in systemAuthList" :label="item.label" :key="item.label"></el-checkbox>
                </el-checkbox-group>
            </el-form-item>
            <el-form-item label="卡号" v-if="cardVisible">
                <el-input v-if="currentRow&&currentRow.detailId" readonly v-model="cardNum"></el-input>
                <el-select v-else v-model="currentRow.cardId"
                           filterable
                           style="width: 100%"
                >
                    <el-option v-for="(item,i) in leftCardList"
                               :key="i"
                               :label="item.cardNo"
                               :value="item.cardId"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="currentRowDialog = false" size="mini">取 消</el-button>
            <el-button type="primary" :loading="submitLoading" @click="doAddUpdateInfo" size="mini">
                保存
            </el-button>
        </span>
    </el-dialog>
    <!--入职清单-->
    <el-dialog title="入职清单" :visible.sync="hireListDialog">
        <el-table
                :data="hireListList"
                style="width: 100%">
            <el-table-column
                    prop="type"
                    label="类型"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="signName"
                    label="确认人"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="signTime"
                    label="确认时间">
            </el-table-column>
        </el-table>
    </el-dialog>
</div>
<script type="text/javascript" src="../../assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="../../assets/js/common.js?v=317"></script>
<script type="text/javascript" src="../../assets/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../assets/js/js.cookie.min.js"></script>
<script type="text/javascript" src="../../assets/js/sqjx.js"></script>
<script type="text/javascript" src="../../../assets/js/custom.js"></script>
<script src="../../assets/js/vue.min.js"></script>
<script src="../../assets/js/elementui.js"></script>
<script type="text/javascript" src="../../../assets/js/print.min.js"></script>

<script>
    let that;
    new Vue({
        el: '#app',
        data: function () {
            return {
                hireListList: [],
                hireListDialog: false,
                cardVisible: false,
                submitLoading: false,

                systemAuthList: [
                    {value: 1, label: '一卡通'},
                    {value: 2, label: '考勤'},
                    {value: 3, label: '型材app'},
                    {value: 4, label: '局域网'},
                    {value: 5, label: 'ERP'}
                ],
                checkedSystemAuthList: [],
                roleList: [{roleName: 'a', roleId: "b"}],
                currentUserRoles: [],
                currentRow: {},
                cardNum: '',
                currentRowDialog: false,
                orgOptions: [],
                statusList: [
                    {value: '2', label: '已登记', checked: true},
                    {value: '3', label: '入职中', checked: true},
                    {value: '1', label: '在职', checked: true},
                    {value: '0', label: '已离职', checked: false},
                    {value: '5', label: '外协', checked: true}],
                checkedStatusList: ['已入职'],
                action: BASE_URL + '/contract/contract/contractUpload',
                contractForm: {},
                fileName: '',
                dialogVisible: false,
                ensureDialog: false,
                hireDialog: false,
                newTrainDialog: false,
                contractDialog: false,
                relationList: [],
                eduList: [],
                skillListStr: '',
                workList: [],
                leftCardList: [],
                orgList: '',
                page: {
                    list: null,
                    currentPage: 1,
                    limit: 30,
                    tableMaxHeight: 250,
                },
                searchForm: {
                    idNum: '',
                    name: '',
                    status: '',
                    account: ''
                },
                tableData: [],
                page: {
                    total: 0,
                    currentPage: 1,
                    rows: 10,
                },
                hireTemplateId: '1468734193443950594',
                trainTemplateId: '1468734220170055681',
                hireApproveList: [],
                trainApproveList: [],
                sexOption: [
                    {
                        value: '男',
                        label: '男'
                    },
                    {
                        value: '女',
                        label: '女'
                    }
                ],
                singleOption: [
                    {
                        value: 1,
                        label: '已婚'
                    },
                    {
                        value: 2,
                        label: '未婚'
                    }
                ],
                eduOption: [
                    {
                        value: 5,
                        label: '初中'
                    },
                    {
                        value: 1,
                        label: '高中'
                    },
                    {
                        value: 6,
                        label: '中专/中技'
                    },
                    {
                        value: 2,
                        label: '大专'
                    },
                    {
                        value: 3,
                        label: '本科'
                    },
                    {
                        value: 4,
                        label: '硕士及以上'
                    },
                ],
            }
        },
        mounted: function () {
            getUrlParam();
            that = this
            this.search();
            that.getOrgOptions();
            that.getAllRoles();
        },
        methods: {
            handleOrgName(name) {
                if (name == '综合部') {
                    return '综合管理部'
                } else if (name == '研发部') {
                    return '研发生产部'

                } else if (name == '质量部') {
                    return '质量管理部'

                } else if (name == '机电部') {
                    debugger
                    return '机械电气部'

                } else if (name == '储运部') {
                    return '储运管理部'

                } else if (name == '安环部') {
                    return '安全环保部'
                } else if (name == '营销部') {
                    return '营销管理部'
                } else if (name == '财务部') {
                    return '财务管理部'
                } else if (name == '李春善') {
                    return '总经理'
                } else if (name == '分管') {
                    return '分管领导'
                } else {
                    return name;
                }
            },
            handleImg(img) {
                return BASE_ANNEX + img + '?token=sqjx'
            },
            openHireList(row) {
                that.hireListDialog = true;
                $.get(`/office/hrUserList/queryHrUserListList?underSignAccount=${row.account}&page=1&rows=50`, function (res) {
                    that.hireListList = res.obj.rows;
                })
            },
            getApproveProcess(instanceId) {

            },
            handlePrint(title) {
                printJS({
                    printable: 'dengji',// // 文档来源：pdf或图像的url，html元素的id或json数据的对象
                    type: 'html', // 可打印的类型。可用的打印选项包括：pdf，html，图像，json和raw-html。
                    targetStyles: ['*'],// 库在打印HTML元素时处理任何样式
                    css: '../../assets/css/elementui.css',
                    header: title,
                    headerStyle: 'text-align: center;',
                    style: '  .el-row .el-form-item {\n' +
                        '            margin-bottom: 0px;\n' +
                        '            text-align: center;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-row .el-col {\n' +
                        '            border-right: 1px solid black;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-row {\n' +
                        '            border: 1px solid black;\n' +
                        '            margin-bottom: -1px !important;\n' +
                        '        }\n' +
                        '        .el-input input{\n' +
                        '            padding:0px;\n' +
                        '        }\n' +
                        '        .el-input .el-input__inner{\n' +
                        '            padding: 0px;\n' +
                        '        }'
                })

            },
            handlePrintHire(title) {
                printJS({
                    printable: 'luyong',// // 文档来源：pdf或图像的url，html元素的id或json数据的对象
                    type: 'html', // 可打印的类型。可用的打印选项包括：pdf，html，图像，json和raw-html。
                    targetStyles: ['*'],// 库在打印HTML元素时处理任何样式
                    css: '../../assets/css/elementui.css',
                    header: title,
                    headerStyle: 'text-align: center;',
                    style: '  .el-row .el-form-item {\n' +
                        '            margin-bottom: 0px;\n' +
                        '            text-align: center;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-row .el-col {\n' +
                        '            border-right: 1px solid black;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-row {\n' +
                        '            border: 1px solid black;\n' +
                        '            margin-bottom: -1px !important;\n' +
                        '        }\n' +
                        '        .el-input input{\n' +
                        '            padding:0px;\n' +
                        '        }\n' +
                        '        .el-input .el-input__inner{\n' +
                        '            padding: 0px;\n' +
                        '        }'
                })

            },
            handlePrintNewTrain(title) {
                printJS({
                    printable: 'peixun',// // 文档来源：pdf或图像的url，html元素的id或json数据的对象
                    type: 'html', // 可打印的类型。可用的打印选项包括：pdf，html，图像，json和raw-html。
                    targetStyles: ['*'],// 库在打印HTML元素时处理任何样式
                    css: '../../assets/css/elementui.css',
                    header: title,
                    headerStyle: 'text-align: center;',
                    style: ' .el-row .el-form-item {\n' +
                        '            margin-bottom: 0px;\n' +
                        '            text-align: center;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-row .el-col {\n' +
                        '            border-right: 1px solid black;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-row {\n' +
                        '            border: 1px solid black;\n' +
                        '            margin-bottom: -1px !important;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-input input {\n' +
                        '            padding: 0px;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-input .el-input__inner {\n' +
                        '            padding: 0px;\n' +
                        '        }\n' +
                        '\n' +
                        '        .el-input__suffix {\n' +
                        '            display: none;\n' +
                        '        }\n' +
                        '\n' +
                        '        .info {\n' +
                        '            text-align: left !important;\n' +
                        '        }\n' +
                        '        h5,p{\n' +
                        '            margin: 0px;\n' +
                        '            text-align: left;\n' +
                        '        }'
                })

            },
            handleLeave(row) {
                this.$confirm('是否将员工状态设置为离职？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.post('/office/user/leave', {account: row.account}, function (res) {
                        if (res.code === 200) {
                            layer.msg(res.msg, {icon: 1});
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                        that.search();
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            handleRemove(row) {
                this.$confirm('删除后数据不可恢复，确认删除？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    if (row.account) {
                        showAlert('有工号的员工无法删除，可点击离职！！！');
                    } else {
                        $.post('/office/hrEmployDetail/deleteRecord', {detailId: row.detailId}, function (res) {
                            closeDialog();
                            if (res.code == 200) {
                                that.search();
                                showMsg(res.msg);
                            } else {
                                showAlert(res.msg);
                            }
                        })
                    }
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            changeSystemAuth(val) {
                // if (!that.currentRow.detailId) {
                //     that.cardVisible = val.some(item => item === '一卡通');
                // }
                that.cardVisible = val.some(item => item === '一卡通');

            },
            doAddUpdateInfo() {
                that.submitLoading = true;
                var params = {}
                var _currentRow = JSON.parse(JSON.stringify(that.currentRow));
                params.name = _currentRow.name;
                if (typeof _currentRow.orgId == 'object') {
                    params.orgId = _currentRow.orgId.pop();

                } else {
                    params.orgId = _currentRow.orgId;

                }
                if (that.currentUserRoles) {
                    params.roles = that.currentUserRoles.join(',')
                }
                let tempSystemAuth = []
                that.checkedSystemAuthList.forEach(x => {
                    that.systemAuthList.forEach(i => {
                        if (i.label === x) {
                            tempSystemAuth.push(i.value)
                        }
                    })
                });
                params.opSys = tempSystemAuth.join(',');
                params.detailId = _currentRow.detailId;
                params.account = _currentRow.account
                $.post(params.detailId ? '/office/hrEmployDetail/updateHrEmployDetail' : '/office/user/addUserInfo', params, function (res) {
                    that.submitLoading = false;
                    that.currentRowDialog = false;
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    that.search();
                })
            },
            handleCurrentRow(row) {
                that.currentRow = {};
                that.currentRowDialog = true;
                that.cardNum = '';
                if (row && row.account) {
                    that.currentRow = row;
                    $.get('/office/hrEmployDetail/platformAuth', {account: row.account}, function (res) {
                        var state = res.obj.state.split(',');
                        state.forEach((x, i) => {
                            if (x == 1) {
                                that.systemAuthList[i]
                                that.checkedSystemAuthList.push(that.systemAuthList[i].label)
                                if (i == 0) {
                                    that.cardVisible = true;
                                }
                            }
                        })
                    });
                    $.post('/office/user/queryUserRoles', {account: row.account}, function (res) {
                        that.currentUserRoles = res.obj.map(item => {
                            return parseInt(item);
                        });
                    });
                    $.get('/office/hrEmployDetail/getCardNum', {account: row.account}, function (res) {
                        if (res.code == 200) {
                            that.cardNum = res.obj.rfkh;
                        } else {
                            that.$message.warning(res.msg)
                        }
                    });

                } else {
                    $.get('/office/hrEmployDetail/getPhysicsNo', function (res) {
                        that.leftCardList = res.obj.cardNoList;
                    });
                    that.currentRow = {};
                    that.currentUserRoles = [16];
                    that.checkedSystemAuthList = [];
                    that.cardVisible = false;
                }
            },
            getOrgOptions() {
                $.post('/office/org/getOrgCascader', {}, function (res) {
                    that.orgOptions = res.obj
                })
            },
            getAllRoles() {
                $.post('/office/role/list', {page: 1, rows: 499}, function (res) {
                    that.roleList = res.rows;
                })
            },
            changeStatus() {
                console.log(that.checkedCities);
            },
            viewHealthPdf() {
                window.open(BASE_ANNEX + that.currentRow.healthPdf + '?token=' + Cookies.get('token'));
            },
            getTokenHeader() {
                return {"token": getToken()}
            },
            getUploadContractData() {
                var param = {
                    account: DEVELOP_ACCOUNT,
                    expireTime: this.contractForm.expTime,
                    supplierId: '-',
                    supplierName: this.currentRow.name,
                    contractType: 'L',//劳动合同
                    userName: getUserName(),
                    userCode: getAccount(),
                }
                return param
            },
            getUploadEnsureData() {
                var param = {
                    account: DEVELOP_ACCOUNT,
                    expireTime: this.contractForm.expTime,
                    supplierId: '-',
                    supplierName: this.currentRow.name,
                    contractType: 'S',//保证书
                    userName: getUserName(),
                    userCode: getAccount(),
                }
                return param
            },
            openContract(row) {
                this.currentRow = row;
                //获取账号信息
                var param = {account: that.currentRow.idNum, contractType: 'L'};
                $.get('/office/hrEmployDetail/getInfo', {detailId: row.detailId}, function (res) {
                    if (res.obj.orgId) {
                        $.post('/contract/contract/getUser', param, function (res) {
                            if (res.code == 200) {
                                if (res.obj.registerFlag == 5) {
                                    //是否有未结束合同
                                    $.get('/contract/contract/getNotFinishContract', param, function (response) {
                                        if (response.code == 200) {
                                            if (response.obj.count === 0) {
                                                that.contractDialog = true;
                                                that.contractForm.expTime = getDateTimeStr(5);
                                                that.contractForm.account = res.obj.account;
                                                that.contractForm.phone = res.obj.trustPhone;
                                                that.contractForm.name = res.obj.trustName;
                                                that.contractForm.lastSignTime = response.obj.lastSignTime;
                                            } else {
                                                showAlert('请您先撤销上一个合同或等待合同锁定再操作');

                                            }
                                        }
                                    })
                                } else if (res.obj.registerFlag == 10) {
                                    showAlert('该账号正在审核中，请您五分钟后再操作')
                                } else {
                                    showAlert('该账号申请失败，请联系管理员')
                                }
                            } else {
                                showAlert(res.msg);
                            }

                        })

                    } else {
                        showAlert('请先填写录用审批或培训审批！')
                    }
                })
            },
            openEnsure(row) {
                this.currentRow = row;
                //获取账号信息
                var param = {account: that.currentRow.idNum, contractType: 'S'};
                $.get('/office/hrEmployDetail/getInfo', {detailId: row.detailId}, function (res) {
                    if (res.obj.orgId) {
                        $.post('/contract/contract/getUser', param, function (res) {
                            if (res.code == 200) {
                                if (res.obj.registerFlag == 5) {
                                    //是否有未结束合同
                                    $.get('/contract/contract/getNotFinishContract', param, function (response) {
                                        if (response.code == 200) {
                                            if (response.obj.count === 0) {
                                                that.ensureDialog = true;
                                                that.contractForm.expTime = getDateTimeStr(5);
                                                that.contractForm.account = res.obj.account;
                                                that.contractForm.phone = res.obj.trustPhone;
                                                that.contractForm.name = res.obj.trustName;
                                                that.contractForm.lastSignTime = response.obj.lastSignTime;
                                            } else {
                                                showAlert('请您先撤销上一个合同或等待合同锁定再操作');

                                            }
                                        }
                                    })
                                } else if (res.obj.registerFlag == 10) {
                                    showAlert('该账号正在审核中，请您五分钟后再操作')
                                } else {
                                    showAlert('该账号申请失败，请联系管理员')
                                }
                            } else {
                                showAlert(res.msg);
                            }

                        })

                    } else {
                        showAlert('请先填写录用审批或培训审批！')
                    }
                })

            },
            handleSendContract() {
                that.$refs.upload.submit();
            },
            handleSendEnsure() {
                that.$refs.uploadEnsure.submit();
            },
            uploadSuccess(res) {
                var param = {
                    contractId: res.obj.contractId,//合同编号
                    dpi: "160",//清晰度
                    expireTime: getDateTimeStr('', '', 5),//五天过期
                    forceReadingSeconds: "0",//
                    isAllowChangeSignaturePosition: "1",//拖拽
                    isDrawSignatureImage: "1",//手动签署
                    pageNum: "3",//头尾骑缝
                    signatureImageName: "",//签名，不填使用系统默认
                    signatureImageRate: "60",//签名大小
                    signaturePositions: [],//位置
                    signer: that.contractForm.account,
                    x: "0.2",//
                    y: "0.89",//
                }
                doPostAsync('/contract/contract/contractSend', param, function (res) {
                    if (res.code == 200) {
                        showAlert('合同已发送，等待签署', 1, function () {
                            that.contractDialog = false;
                        })
                    } else {
                        showAlert(res.msg);
                    }

                })
            },
            uploadEnsureSuccess(res) {
                var param = {
                    contractId: res.obj.contractId,//合同编号
                    dpi: "160",//清晰度
                    expireTime: getDateTimeStr('', '', 5),//五天过期
                    forceReadingSeconds: "0",//
                    isAllowChangeSignaturePosition: "1",//拖拽
                    isDrawSignatureImage: "1",//手动签署
                    pageNum: "3",//头尾骑缝
                    signatureImageName: "",//签名，不填使用系统默认
                    signatureImageRate: "60",//签名大小
                    signaturePositions: [],//位置
                    signer: that.contractForm.account,
                    x: "0.72",//
                    y: "0.75",//
                }
                doPostAsync('/contract/contract/contractSend', param, function (res) {
                    if (res.code == 200) {
                        showAlert('合同已发送，等待签署', 1, function () {
                            that.ensureDialog = false;
                        })
                    } else {
                        showAlert(res.msg);
                    }

                })
            },
            chooseFile() {
                var input = document.createElement("input");
                input.type = "file";
                input.click(); //代码执行到这里，本地文件选择框便会打开！
                input.onchange = function () {
                    cbAnnexFile = input.files[0];
                    if (cbAnnexFile.name.indexOf('pdf') == -1) {
                        showAlert('请上传pdf格式文件');
                        return;
                    }
                    that.fileName = cbAnnexFile.name;
                    var formData = new FormData();
                    formData.append("file", cbAnnexFile);
                    var result = uploadFile(formData);
                    if (result.code == 200) {
                        that.currentRow.healthPdf = result.obj.storeName;
                    }
                };
            },
            changeLockStatus(row) {
                if (row.lock == 2) {
                    that.$confirm('该员工还没有点击提交，确定修改状态为已锁定？').then(res => {
                        row.lock = 3
                        that.currentRow = row;
                        $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res1) {
                            if (res1.code == 200) {
                                that.handleCreateContractAccount();
                                that.search();
                            }
                        })
                    })
                } else if (row.lock == 3) {
                    //由锁定状态变为未填写
                    row.lock = 2;
                    that.currentRow = row;
                    $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res1) {
                        if (res1.code == 200) {
                            that.search();
                        }
                    })
                } else if (row.lock == 1 || (!row.lock)) {
                    row.lock = 3
                    that.currentRow = row;
                    $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res1) {
                        if (res1.code == 200) {
                            that.handleCreateContractAccount();
                            that.search();
                        }
                    })
                } else {
                    showAlert('未知状态，请联系管理员');
                    return
                }


            },
            handleClose() {
                this.dialogVisible = false
            },
            search: function () {
                var params = this.searchForm;
                params.page = this.page.currentPage;
                params.rows = this.page.rows;
                params.status = [];
                that.statusList.filter(x => {
                    if(x.checked){
                        params.status.push(x.value)
                    }
                })
                params.status = params.status.join(',');
                $.post('/office/hrEmployDetail/queryHrEmployDetailList', params, function (res) {
                    that.tableData = res.obj.rows
                    that.page.total = res.obj.total
                })
            },
            handleOrgChange() {

            },
            handleEdit(row) {
                this.dialogVisible = true;
                this.currentRow = row;
                that.currentRow.trainTime = formatDate(new Date())
                this.getUserRelation();
                this.getUserStudy();
                this.getUserSkill();
                this.getUserWork();
            },
            openNewTrain(row) {
                that.newTrainDialog = true;
                this.currentRow = row
                that.currentRow.trainTime = formatDate(new Date())
                this.selectMainOrgList();
                this.getTrainFlowTemplate()
            },
            openHire(row) {
                that.hireDialog = true;
                this.currentRow = row;
                that.currentRow.hireTime = that.currentRow.hireTime ? that.currentRow.hireTime : formatDate(new Date());
                this.selectMainOrgList();
                this.getHireFlowTemplate()
            },
            getUserRelation() {
                if (!this.currentRow.idNum) {
                    return
                }
                that.relationList = [];
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserRelation/getHrUserRelation', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        that.relationList = res.obj;
                    }
                })
            },
            getUserStudy() {
                if (!this.currentRow.idNum) {
                    return
                }
                that.eduList = [];
                if (!this.currentRow.idNum) {
                    return
                }
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserStudy/getHrUserStudy', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        that.eduList = res.obj;
                    }
                })
            },
            getUserSkill() {
                if (!this.currentRow.idNum) {
                    return
                }
                that.skillListStr = '';
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserSkill/getHrUserSkill', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        var array = []
                        res.obj.forEach(item => {
                            array.push(item.skill)
                        })
                        that.skillListStr = array.join(',') || '无'

                    }
                })
            },
            getUserWork() {
                if (!this.currentRow.idNum) {
                    return
                }
                that.workList = [];
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserWork/getHrUserWork', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        that.workList = res.obj;
                    }
                })
            },
            handleCurrentChange(currentPage) {
                that.page.currentPage = currentPage;
                that.search()
            },
            handleSizeChange() {
            },
            selectMainOrgList() {
                $.post('/office/org/queryOrg', function (res) {
                    that.orgList = res.obj;

                })
            },
            getHireFlowTemplate() {
                var templateId = that.hireTemplateId
                $.get('/office/flowWorkTemplate/startFlowName', {templateId: templateId}, function (res) {
                    that.hireApproveList = res.obj;
                    if (that.currentRow.orgId == 2) {
                        that.hireApproveList[0][0].hide = true;
                        that.hireApproveList[3][0].hide = true;
                    } else if (that.currentRow.orgId == 91) {
                        that.hireApproveList[3][0].hide = true;
                    }
                    if (that.currentRow.hireInstanceId) {
                        $.post('/office/flowStepInstance/queryInstanceAndProcess', {instanceId: that.currentRow.hireInstanceId}, function (res) {
                            let hireApproveResult = [];
                            res.obj.flowStepApprove.process.forEach(item => {
                                if (item.status === 1) {
                                    hireApproveResult.push({
                                        comment: item.comment,
                                        name: "同意  " + item.nickName,
                                        approveDate: item.updateTime
                                    })
                                }
                            });
                            let count = 0;
                            that.hireApproveList = that.hireApproveList.map(item => {
                                if (!item[0].hide) {
                                    item[0].approveInfo = hireApproveResult[count]
                                    count += 1
                                }
                                return item;
                            })
                            console.log('that.hireApproveList', that.hireApproveList)
                        })
                    } else {
                        //---
                    }

                })
            },
            getTrainFlowTemplate() {
                var templateId = that.trainTemplateId
                $.get('/office/flowWorkTemplate/startFlowName', {templateId: templateId}, function (res) {

                    that.trainApproveList = res.obj.map(item => {
                        return item[0];
                    });
                    if (that.currentRow.newTrainInstanceId) {
                        $.post('/office/flowStepInstance/queryInstanceAndProcess', {instanceId: that.currentRow.newTrainInstanceId}, function (res) {
                            let trainApproveResult = [];
                            res.obj.flowStepApprove.process.forEach(item => {
                                if (item.status === 1) {
                                    trainApproveResult.push({
                                        comment: item.comment,
                                        name: item.nickName,
                                        approveDate: item.updateTime
                                    })
                                }
                            });
                            let count = 0;
                            that.trainApproveList = that.trainApproveList.map(item => {
                                item.approveInfo = trainApproveResult[count];
                                count++;
                                return item;
                            });

                            console.log('that.trainApproveList', that.trainApproveList)
                        })
                    } else {
                        //---
                    }

                })
            },
            handleSaveHealthPdf() {
                layer.confirm('确认提交？', function () {
                    that.dialogVisible = false;
                    $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res1) {
                        if (res1.code == 200) {
                            showAlert('更新员工信息成功', 1, function () {
                                closeDialog();
                            })
                        }
                    })
                })
            },
            handleSaveHire() {
                var a = that.currentRow.orgId;
                var b = that.currentRow.job;
                var c = that.currentRow.audition;
                if (!a) {
                    showAlert('部门必填')
                    return
                }
                if (!b) {
                    showAlert('岗位必填')
                    return
                }
                if (!c) {
                    showAlert('面试结论必填')
                    return
                }

                layer.confirm('确认提交员工录用审批？', function () {
                    $.get('/office/user/getMainOrgByOrgId', {orgId: that.currentRow.orgId}, function (res1) {
                        if (res1.code == 200) {
                            var param1 = {
                                templateId: that.hireTemplateId,
                                dynamicOrgId: res1.obj.orgId,
                                authRoleId: 29
                            };
                            $.get('/office/flowWorkTemplate/getHirePreviewNodeList', param1, function (res) {
                                that.hireDialog = false;
                                if (res.code == 200) {
                                    var param2 = {};
                                    param2.userId = getUserId();
                                    param2.userName = getUserName()
                                    param2.title = '员工录用审批表';
                                    param2.templateId = that.hireTemplateId;
                                    param2.content = 'apply/hire'
                                    param2.annex = that.currentRow.idNum;
                                    param2.touch = BASE_URL + '/office/flowStepInstance/hireCb';
                                    param2.approveNodes = res.obj.map(item => {
                                        return {orgId: item}
                                    });
                                    param2.approveNodes = JSON.stringify(param2.approveNodes)
                                    postJson('/office/flowWork/createFlow2Approve', param2, function (res3) {
                                        if (res3.code == 200) {
                                            that.currentRow.hireInstanceId = res3.obj.instanceId;
                                            $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res4) {
                                                if (res4.code == 200) {
                                                    showMsg('添加成功', 1)
                                                } else {
                                                    showAlert(res4.msg)
                                                }

                                            })
                                        } else {
                                            showAlert(res3.msg);
                                        }
                                    });
                                } else {
                                    showAlert(res.msg)
                                }
                            })
                        } else {
                            showAlert('组织机构不存在，请联系管理员' + that.currentRow.orgId)
                        }

                    });

                })
            },
            handleSaveNewTrain() {
                var a = that.currentRow.orgId
                var b = that.currentRow.job
                if (!a) {
                    showAlert('部门必填')
                    return
                }
                if (!b) {
                    showAlert('岗位必填')
                    return
                }
                layer.confirm('确认提交员工培训信息？', function () {
                    that.newTrainDialog = false;
                    var param1 = {
                        templateId: that.trainTemplateId,
                        dynamicOrgId: that.currentRow.orgId,
                        authRoleId: 30
                    };
                    $.get('/office/flowWorkTemplate/getHirePreviewNodeList', param1, function (res) {
                        if (res.code == 200) {
                            var param2 = {};
                            param2.userId = getUserId();
                            param2.userName = getUserName()
                            param2.title = '入职培训记录';
                            param2.templateId = that.trainTemplateId;
                            param2.content = 'apply/newTrain';
                            param2.annex = that.currentRow.idNum;
                            param2.touch = BASE_URL + '/office/flowStepInstance/trainCb';
                            param2.approveNodes = res.obj.map(item => {
                                return {orgId: item}
                            });
                            param2.approveNodes = JSON.stringify(param2.approveNodes)
                            postJson('/office/flowWork/createFlow2Approve', param2, function (res3) {
                                if (res3.code == 200) {
                                    that.currentRow.newTrainInstanceId = res3.obj.instanceId;
                                    $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res4) {
                                        if (res4.code == 200) {
                                            showMsg('添加成功', 1)
                                        } else {
                                            showAlert(res4.msg)
                                        }

                                    })
                                } else {
                                    showAlert(res3.msg);
                                }

                            })
                        } else {
                            showAlert(res.msg)
                        }
                    });
                })

            },
            /**
             * 锁定员工后生成工号
             */
            handleCreateContractAccount() {
                var param = {};
                param.supplierId = supplierId;
                param.supplierName = '宿迁南钢金鑫轧钢有限公司';
                param.supplierType = 3;//普通员工
                param.userType = 1;
                param.account = that.currentRow.idNum;
                param.identityNum = that.currentRow.idNum
                param.trustName = that.currentRow.name
                param.trustPhone = that.currentRow.phone;
                $.post('/contract/contract/addContractUser', param, function (res) {
                    console.log('账号信息', res.msg)
                })

            },
            exportData() {
                window.location = BASE_URL + '/office/export/empList?token=' + Cookies.get('token');
            }
        },
    })
</script>
</body>
</html>
